package org.crazyit.cloud.use3;


import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * 要执行的命令，这个命令做的事情就是输出一个index的值。（msg）
 */
public class MyCommand extends HystrixCommand<String> {

    private int index;

    public MyCommand(int index) {
        super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("TestGroupKey")));
        this.index = index;
    }

    @Override
    protected String run() throws Exception {
        Thread.sleep(500);
        System.out.println("执行方法，当前索引：" + index);
        return "";
    }

    @Override
    protected String getFallback() {
        System.out.println("执行回退，当前索引：" + index);
        return "";
    }

    public static void main(String[] args) {
        System.out.println("吱吱吱吱吱吱吱吱在");
    }
}


